From: Max Semenik Date: Mon, 15 Sep 2014 22:47:30 +0000 (-0700) Subject: Deprecate HTMLFileCache::newFromTitle() in favor of constructor X-Git-Tag: 1.31.0-rc.0~13935^2 X-Git-Url: http://git.cyclocoop.org/%7D%7Cconcat%7B?a=commitdiff_plain;h=0fddd42ca4eca5c7521bb81d7d21757b4454f1b9;p=lhc%2Fweb%2Fwiklou.git Deprecate HTMLFileCache::newFromTitle() in favor of constructor Change-Id: I903e68fc1f486501d790ca69146ecb835d90c9cc --- diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php index 9213c021ef..545a46f63c 100644 --- a/includes/MediaWiki.php +++ b/includes/MediaWiki.php @@ -560,7 +560,7 @@ class MediaWiki { wfProfileIn( 'main-try-filecache' ); if ( HTMLFileCache::useFileCache( $this->context ) ) { // Try low-level file cache hit - $cache = HTMLFileCache::newFromTitle( $title, $action ); + $cache = new HTMLFileCache( $title, $action ); if ( $cache->isCacheGood( /* Assume up to date */ ) ) { // Check incoming headers to see if client has this cached $timestamp = $cache->cacheTimestamp(); diff --git a/includes/actions/HistoryAction.php b/includes/actions/HistoryAction.php index 523da686c4..8522e560b3 100644 --- a/includes/actions/HistoryAction.php +++ b/includes/actions/HistoryAction.php @@ -110,7 +110,7 @@ class HistoryAction extends FormlessAction { # Fill in the file cache if not set already $useFileCache = $config->get( 'UseFileCache' ); if ( $useFileCache && HTMLFileCache::useFileCache( $this->getContext() ) ) { - $cache = HTMLFileCache::newFromTitle( $this->getTitle(), 'history' ); + $cache = new HTMLFileCache( $this->getTitle(), 'history' ); if ( !$cache->isCacheGood( /* Assume up to date */ ) ) { ob_start( array( &$cache, 'saveToFileCache' ) ); } diff --git a/includes/cache/HTMLFileCache.php b/includes/cache/HTMLFileCache.php index 91580f978f..033941faca 100644 --- a/includes/cache/HTMLFileCache.php +++ b/includes/cache/HTMLFileCache.php @@ -35,21 +35,28 @@ class HTMLFileCache extends FileCacheBase { * @param string $action * @throws MWException * @return HTMLFileCache + * + * @deprecated Since 1.24, instantiate this class directly */ public static function newFromTitle( $title, $action ) { - $cache = new self(); + return new self( $title, $action ); + } + /** + * @param Title|string $title Title object or prefixed DB key string + * @param string $action + * @throws MWException + */ + public function __construct( $title, $action ) { $allowedTypes = self::cacheablePageActions(); if ( !in_array( $action, $allowedTypes ) ) { - throw new MWException( "Invalid filecache type given." ); + throw new MWException( 'Invalid file cache type given.' ); } - $cache->mKey = ( $title instanceof Title ) + $this->mKey = ( $title instanceof Title ) ? $title->getPrefixedDBkey() : (string)$title; - $cache->mType = (string)$action; - $cache->mExt = 'html'; - - return $cache; + $this->mType = (string)$action; + $this->mExt = 'html'; } /** @@ -211,7 +218,7 @@ class HTMLFileCache extends FileCacheBase { } foreach ( self::cacheablePageActions() as $type ) { - $fc = self::newFromTitle( $title, $type ); + $fc = new self( $title, $type ); $fc->clearCache(); } diff --git a/includes/db/DatabaseError.php b/includes/db/DatabaseError.php index 8229c99565..2dfec41dd7 100644 --- a/includes/db/DatabaseError.php +++ b/includes/db/DatabaseError.php @@ -306,7 +306,7 @@ EOT; } } - $cache = HTMLFileCache::newFromTitle( $t, 'view' ); + $cache = new HTMLFileCache( $t, 'view' ); if ( $cache->isCached() ) { return $cache->fetchText(); } else { diff --git a/includes/page/Article.php b/includes/page/Article.php index 984531675c..daf331149e 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -1841,7 +1841,7 @@ class Article implements Page { $called = true; if ( $this->isFileCacheable() ) { - $cache = HTMLFileCache::newFromTitle( $this->getTitle(), 'view' ); + $cache = new HTMLFileCache( $this->getTitle(), 'view' ); if ( $cache->isCacheGood( $this->mPage->getTouched() ) ) { wfDebug( "Article::tryFileCache(): about to load file\n" ); $cache->loadFromFileCache( $this->getContext() );